package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.FlowFormEquipmentServerApply;
import com.glsc.ngateway.common.base.domainmapper.FlowFormEquipmentServerApplyMapper;
import com.glsc.ngateway.common.api.flowable.dto.task.formData.equipment.domainDto.FlowFormEquipmentServerApplyDto;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * FlowFormEquipmentServerApply转换器
 * @author xuchang
 */
public class FlowFormEquipmentServerApplyConverter extends AbstractFlowFormDataConverter {
    public static FlowFormEquipmentServerApplyDto do2Dto(FlowFormEquipmentServerApply apply) {
        if (Objects.isNull(apply)) {
            return null;
        }
        FlowFormEquipmentServerApplyDto applyDto = FlowFormEquipmentServerApplyMapper.INSTANCE.domain2dto(apply);
        applyDto.setAppendicesFileList(converter2FileList(apply.getAppendicesFileIdList()));
        return applyDto;
    }

    public static List<FlowFormEquipmentServerApplyDto> do2Dto(List<FlowFormEquipmentServerApply> applyList) {
        return CollectionUtils.isEmpty(applyList) ? java.util.Collections.emptyList() : applyList.stream().map(FlowFormEquipmentServerApplyConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormEquipmentServerApply dto2Do(FlowFormEquipmentServerApplyDto applyDto) {
        if (Objects.isNull(applyDto)) {
            return null;
        }
        FlowFormEquipmentServerApply apply = FlowFormEquipmentServerApplyMapper.INSTANCE.dto2domain(applyDto);
        apply.setAppendicesFileIdList(converter2FileIdList(applyDto.getAppendicesFileList()));
        return apply;
    }

    public static List<FlowFormEquipmentServerApply> dto2Do(List<FlowFormEquipmentServerApplyDto> applyDtoList) {
        return CollectionUtils.isEmpty(applyDtoList) ? java.util.Collections.emptyList() : applyDtoList.stream().map(FlowFormEquipmentServerApplyConverter::dto2Do).collect(Collectors.toList());
    }

}
